package com.zxst.controller;

import com.zxst.service.ReportService;
import com.zxst.util.JsonResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/report")
public class ReportController {

    @Resource
    private ReportService reportService;

    //统计截止到今天一年内会员数量折线图
    @RequestMapping("/getMemeberCount")
    public JsonResult  getMemeberCount(){
        return  reportService.getMemeberCount();
    }
    //统计商品销售金额柱状图
    @RequestMapping("/getGoodsAndMoney")
    public JsonResult  getGoodsAndMoney(){
        return reportService.getGoodsAndMoney();
    }

    //统计用户购买不同商品数量
    @RequestMapping("/getBuyGoodsInfo")
    public JsonResult  getBuyGoodsInfo(){
        List<Object> list = new ArrayList<Object>();
        List<Object> row1 = new ArrayList<>();
        //['product', '2015', '2016', '2017'],
        row1.add("product");
        row1.add("苹果电脑");
        row1.add("华为手机");
        row1.add("小米汽车");
        list.add(row1);

        List<Object> row2 = new ArrayList<>();
        row2.add("张三");
        row2.add(5);
        row2.add(3);
        row2.add(2);
        list.add(row2);

        List<Object> row3 = new ArrayList<>();
        row3.add("李四");
        row3.add(10);
        row3.add(8);
        row3.add(1);
        list.add(row3);

        List<Object> row4 = new ArrayList<>();
        row4.add("王五");
        row4.add(5);
        row4.add(3);
        row4.add(2);
        list.add(row4);

        List<Object> row5 = new ArrayList<>();
        row5.add("小黑");
        row5.add(3);
        row5.add(2);
        row5.add(5);
        list.add(row5);

        return  new JsonResult(200,null,list);
    }




    //对接后台数据库数据(每种商品销售数量饼状图)
    @RequestMapping("/getGoodsNumInfo")
    public JsonResult  getGoodsNumInfo(){
        return reportService.getGoodsNumInfo();
    }


    @RequestMapping("/getBusinessReportData")
    public JsonResult  getBusinessReportData(){
        return reportService.getBusinessReportData();
    }



}
